package com.shundr.auth.user.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shundr.auth.R;
import com.shundr.auth.user.model.AuthDriverInfo;
import com.shundr.auth.user.model.AuthOwnnerInfo;

/**
 * 
 * AuthItemAdapter 认证列表适配器
 * 
 * 
 * @author larry 2015-4-13 下午4:26:47
 * @version 1.0.0
 *
 */
public class AuthOwnnerItemAdapter extends BaseAdapter {
	public List<AuthOwnnerInfo> mList;
	private Context mContext;

	@Override
	public int getCount() {
		return mList.size();
	}

	@Override
	public Object getItem(int index) {
		return mList.get(index);
	}

	@Override
	public long getItemId(int id) {
		return id;
	}

	public AuthOwnnerItemAdapter(List<AuthOwnnerInfo> mlist, Context mContext) {
		super();
		this.mList = mlist;
		this.mContext = mContext;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup viewGroup) {
		ViewHold viewHold = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.item_auth_info, null);
			viewHold = new ViewHold();
			viewHold.tvName = (TextView) convertView.findViewById(R.id.tv_name);
			viewHold.tvManager = (TextView) convertView
					.findViewById(R.id.tv_manager);
			convertView.setTag(viewHold);
		} else {
			viewHold = (ViewHold) convertView.getTag();
		}
		try {
			AuthOwnnerInfo info = mList.get(position);
			viewHold.tvName.setText(info.getName());
			viewHold.tvManager.setText(info.getPhone());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return convertView;
	}

	static class ViewHold {
		TextView tvName;
		TextView tvManager;
	}
}
